import {Injectable} from '@angular/core';
import {RouterService} from '@kylin/router';
import {UserService} from '@kylin/core';
import {CacheService} from '@kylin/cache';
import {environment} from '../../environments/environment';
import {HttpService} from '@kylin/http';
import {Subject} from 'rxjs';

@Injectable()
export class HomeService {

    private changeNzCollapsed = new Subject();
    private changeFullscreen = new Subject();

    nzCollapsedObservable = this.changeNzCollapsed.asObservable();
    fullscreenObservable = this.changeFullscreen.asObservable();


    constructor(private routerService: RouterService,
                private userService: UserService,
                private http: HttpService,
                private cacheService: CacheService
    ) {
    }

    $changeFullscreenObservable(value) {
        this.changeFullscreen.next(value)
    }

    $changeNzCollapsedObservable(value) {
        this.changeNzCollapsed.next(value);
    }

    /**
     * 登出
     */
    logout() {
        this.routerService.navigate('/login');
        this.cacheService.remove('siderData');
        this.cacheService.remove('token');
    }

    /**
     * 用于在进入home页面时候验证用户是否已经登陆,如果没有登陆,那么跳转到登陆页面
     */

    /*getSidebarMenuData() {
        if (false) {
            return this.cacheService.get('siderData').menuList;
        } else {
            return [
                {
                    name: '首页',
                    url: '/home/front-page',
                    icon: 'windows'
                },
                {
                    name: '数据导入',
                    url: '/home/data-import',
                    icon: 'rise'
                },
                {
                    name: '地图统计',
                    url: '/home/statistical-map',
                    icon: 'global',
                },
                {
                    name: '个人中心',
                    url: '',
                    icon: 'user',
                    childMenu: [
                        {
                            name: '我的发布',
                            icon: '',
                            url: '/home/personal-center/release',
                        },
                        {
                            name: '地图数据集系统',
                            icon: '',
                            url: '/home/personal-center/data-set'
                        }
                    ]
                },
                {
                    name: '企业平台',
                    url: '/home/platform',
                    icon: 'global',
                },
            ];
        }
    }*/

    getSidebarMenuData() {
        if (false) {
            return this.cacheService.get('siderData').menuList;
        } else {
            return [
                {
                    name: '首页',
                    url: '/home/home-page',
                    icon: 'iconyiliaohangyedeICON-',
                },
                {
                    name: '生态资源',
                    icon: 'iconkaifangdeshengtai',
                    childMenu: [
                        {
                            name: '地图',
                            url: '/home/front-page'
                        },
                        {
                            name: '大屏展示',
                            url: '/home/not-developed'
                        }
                    ]
                },
                {
                    name: '常规监测',
                    icon: 'iconjiance',
                    childMenu: [
                        {
                            name: '实时监测',
                            url: '/home/not-developed'
                        },
                        {
                            name: '地面调查',
                            url: '/home/not-developed'
                        }
                    ]
                },
                {
                    name: '遥感监测',
                    icon: 'iconyaokong',
                    childMenu: [
                        {
                            name: '专题监测',
                            url: '/home/not-developed'
                        },
                        {
                            name: '动态监测',
                            url: '/home/not-developed'
                        }
                    ]
                },
                {
                    name: '移动巡护',
                    icon: 'iconyidong01',
                    childMenu: [
                        {
                            name: '巡护工作',
                            url: '/home/not-developed'
                        },
                        {
                            name: '记录统计',
                            url: '/home/not-developed'
                        }
                    ]
                },
                {
                    name: '生态评价',
                    icon: 'iconpingjia',
                    url: '/home/not-developed',
                },
                {
                    name: '生态保护',
                    icon: 'iconbaohu',
                    url: '/home/not-developed',
                },
            ];
        }
    }

}
